<?php include $this->admin_tpl('meta', 'admin');?>
<link rel="stylesheet" type="text/css" href="<?php echo STATIC_URL;?>plugin/swiper/css/swiper.min.css" />
<link rel="stylesheet" type="text/css" href="<?php echo STATIC_URL;?>admin/yzm_admin/css/yzm.admin.home.css" />
<title>我的桌面</title>
<meta name="referrer" content="no-referrer" />
<style>
.btn{border:1px solid #1e9fff;padding:3px 8px;height:25px;line-height:25px;color:#1e9fff;white-space:nowrap;display:inline-block;margin-left:5px;}
.btn:hover{decoration:none;background:#1e9fff;color:#fff;}
</style>
</head>
<body>
<div class="page-container" style="margin:0;padding:0 10px;">
	<div class="explain" style="margin:15px;"> 
	   <p>如需统计看板，请联系管理员.</p>
	</div>
	<div class="col-md-6">
		<div class="panel panel-default" style="height:810px;position:relative;padding:0;margin-bottom:20px;">
			<div class="panel-header" style="height:20px;"><span class="f-l">销量榜单</span></div>
			<div class="panel-body" style="padding:0;">
				<div class="" style="">
					<div id="loading_sale" style="height:200px;line-height:200px;text-align:center;"><img src="/common/static/plugin/layer/theme/default/loading-1.gif"></div>
					<div id="container_sale" style="padding:5px;padding-bottom:0;">
					</div>
					<div style="text-align:center;margin-top:3px;" id="page">
						<a href="javascript:page_prev()" title="上一页" class="btn">上一页</a>
						<a href="javascript:page_next()" title="下一页" class="btn">下一页</a>
					</div>
				</div>

  
				<span class="f-r" style="position:absolute;top:3px;right:10px;">
				<span class="label label-success radius" onclick="sale(1)" style="cursor:pointer">刷新</span>
					 <span class="select-box inline" style="background:#fff;">
						<select name="brand_sale" class="select select_sale">
							<option value="0">所有品牌</option>
							<?php 		
							foreach(get_brand_list() as $val){
								$str = '';
								echo '<option value="'.$val.'">'.$val.'</option>';
							}
							?>
						</select>
					</span>
					 <span class="select-box inline" style="background:#fff;">
						<select name="days_sale" class="select select_sale">
							<option value="1">昨日</option>
							<option value="3">3天</option>
							<option value="7">7天</option>
							<option value="30">30天</option>
						</select>
					</span>
					<input name="is_ys_checkbox_sale" type="checkbox" checked> 佑晟
				</span>
				
			</div>
		</div>
	</div>

	<div class="col-md-6">
	
		<div class="panel panel-default" style="border:0;">
			<div class="panel panel-default" style="height:340px;position:relative;padding:0;margin-bottom:20px;">
				<div class="panel-header" style="height:20px;"><span class="f-l">缺货统计</span></div>
				<div class="panel-body" style="padding:0;">
	  
					<div class="" style="padding:0px;">
						<div id="loading_suggest" style="height:200px;line-height:200px;text-align:center;"><img src="/common/static/plugin/layer/theme/default/loading-1.gif"></div>
						<div id="container_suggest" style="padding:5px;padding-bottom:0;"></div>
					</div>
	  
					<span class="f-r" style="position:absolute;top:8px;right:10px;">
					<span class="label label-success radius" onclick="suggest()" style="cursor:pointer">刷新</span>
					</span>
					
				</div>
			</div>
		</div>
	
		<div class="panel panel-default">
			<div class="panel-header">系统信息</div>
			<div class="panel-body yzm-box-container">
				<table class="table table-border table-hover">
				  <tr>
				  	<td width="100">系统版本</td>
				  	<td><a href="javascript:;">佑晟电商系统</a> <?php echo YZMCMS_VERSION;?>(<?php echo YZMCMS_UPDATE;?>)</td>
				  	<td>系统框架</td>
				  	<td><a href="javascript:;">YZMPHP V<?php echo YZMPHP_VERSION;?></a> </td>
				  </tr>
				  <tr>
				  	<td>前端框架</td>
				  	<td><a href="http://www.h-ui.net" target="_blank">H-ui前端框架</a> </td>
					<td>用户名</td>
					<td><?php echo $_SESSION['admininfo']['adminname'];?></td>
				  </tr>
				  <tr>
					<td>所属角色</td>
					<td><?php echo $_SESSION['admininfo']['rolename'];?></td>
					<td>上次登录时间</td>
					<td><?php echo $_SESSION['admininfo']['logintime'] ? date('Y-m-d H:i:s', $_SESSION['admininfo']['logintime']) : '首次登录';?></td>
				  </tr>
				  <tr>
					<td>上次登录IP</td>
					<td><?php echo $_SESSION['admininfo']['loginip'] ? $_SESSION['admininfo']['loginip'] : '首次登录';?></td>
					<td>登录日志</td>
					<td><a data-title="登录日志"  _href="<?php echo U('admin_log/admin_login_log_list');?>" onclick="Hui_admin_tab(this)" href="javascript:void(0)">点击查看</a></td>
				  </tr>
				  <?php if(is_file(YZMPHP_PATH.'cache/error_log.php')){?>
				  <tr>
				  	<td>安全提示</td>
				  	<td colspan=3>
				  		<span class="c-red">错误日志（/cache/error_log.php）</span>
			  			<?php echo sizecount(filesize(YZMPHP_PATH.'cache/error_log.php'));?> 
			  			<a href="javascript:yzm_clear_log()" title="清除日志" class="btn">清除</a>
						<a href="javascript:open_log()" title="清除日志" class="btn">查看</a>
				  	</td>
				  </tr>
				  <?php } ?>
				</table>
			</div>
		</div>
		
		<div class="panel panel-default mt-20">
			<div class="panel-header">软件环境</div>
			<div class="panel-body">
				<table class="table table-border table-hover">
				  <tr>
					<td>WEB服务器</td>
					<td><?php echo $_SERVER['SERVER_SOFTWARE'];?></td>
					<td>PHP版本</td>
					<td><?php echo PHP_VERSION;?></td>
				  </tr>
				  <tr>
					<td>MySQL版本</td>
					<td><?php echo D('admin')->version();?></td>
					<td>服务器操作系统 </td>
					<td><?php echo php_uname('s');?></td>
				  </tr>
				  <tr>
				  	<td>REGISTER_GLOBALS</td>
				  	<td><?php echo ini_get('register_globals') ? '<span style="color:red;">ON</span>' : 'OFF';?></td>
				  	<td>MAGIC_QUOTES_GPC</td>
				  	<td><?php echo MAGIC_QUOTES_GPC ? '<span style="color:red;">ON</span>' : 'OFF';?></td>
				  </tr>
				  <tr>
				  	<td>最大上传限制（UPLOAD_MAX_FILESIZE） </td>
				  	<td><?php echo ini_get('file_uploads') ? ini_get('upload_max_filesize') : 'Disabled';?></td>
				  	<td>最大执行时间（MAX_EXECUTION_TIME）</td>
				  	<td><?php echo ini_get('max_execution_time').'秒';?></td>
				  </tr>
				  <tr>
				  	<td>服务器域名 </td>
				  	<td><?php echo $_SERVER['HTTP_HOST'];?></td>
				  	<td>服务器端口 </td>
				  	<td><?php echo $_SERVER['SERVER_PORT'];?></td>
				  </tr>
				</table>
			</div>
		</div>
	
	</div>
	

</div>
<?php include $this->admin_tpl('footer', 'admin');?>
<script type="text/javascript">
var page = 1;
var clear = 0;
var clear_sale = 0;
function yzm_clear_log(){
	layer.confirm('确认要清除错误日志吗？',function(index){
		$.ajax({
			type: 'GET',
			url: '<?php echo U('index/public_clear_log');?>', 
			dataType: "json", 
			success: function (msg) {
				if(msg.status == 1){
					layer.msg(msg.message, {icon:1,time: 800}, function(){
					  window.location.reload();     
					});
				}else{
					layer.msg(msg.message, {icon:2,time: 2500});
				}
			}
		})	
	});
	
}
function open_log(){
	let url = '<?php echo U('public_open_log')?>';
	layer.open({  
		type: 2,  
		title: '查看错误日志',  
		shadeClose: true,  
		shade: 0.2,  
		area: ['1000px', '800px'],  
		content: url,
		success: function(layero, index){
			
		}
	}) 
}
$('.select_sale').change(function(){
	if($(this).attr('name') == 'brand_sale'){
		$('input[name="is_ys_checkbox_sale"]').attr("checked", false);
	}
	sale();
})
$('input[name="is_ys_checkbox_sale"]').click(function(){
	$('select[name="brand_sale"]').val("0");
	sale();
});
function page_prev(){
	if(page>1){
		page = page-1;
		sale();
	}else{
		layer.msg('已首页！');
	}
}
function page_next(){
	if(page<10){
		page = page+1;
		sale();
	}else{
		layer.msg('已是最后一页！');
	}
}
function sale(clear_sale){
	$('#page').hide();
	$('#container_sale').hide();
	$('#loading_sale').show();
	let brand = $('select[name="brand_sale"]').val();
	let days = $('select[name="days_sale"]').val();
	let is_ys = $('input[name="is_ys_checkbox_sale"]').is(':checked') ? 1 : 0;
	if(is_ys){
		$('select[name="brand_sale"]').val(0);
	}
	$.ajax({
		type: 'GET',
		url: "<?php echo U('public_sale');?>",
		data: {brand:brand,days:days,page:page,is_ys:is_ys,clear:clear_sale},
		dataType: "html", 
		success: function (res) {
			$('#container_sale').html(res);
			$('#page').show();
			$('#container_sale').show();
			$('#loading_sale').hide();
		}
	});
}
function suggest(clear_suggest){
	$('#container_suggest').hide();
	$('#loading_suggest').show();
	$.ajax({
		type: 'GET',
		url: "<?php echo U('public_suggest');?>",
		data: {},
		dataType: "html", 
		success: function (res) {
			$('#container_suggest').html(res);
			layer.closeAll('loading');
			$('#container_suggest').show();
			$('#loading_suggest').hide();
		}
	});
}
sale();
suggest();
</script>
</body>
</html>